﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace AttentenceCheckSystem
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            MonthPicker.SelectedDate = DateTime.Now;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ExcelDbObject excelDbObject = new ExcelDbObject();
            if (excelDbObject.Open())
            {
                ExcelSheetSelectorWindow excelSheetSelector = new ExcelSheetSelectorWindow();
                excelSheetSelector.DataContext = excelDbObject.Sheets;
                if (excelSheetSelector.ShowDialog() == true)
                {
                    DataTable dataTable = excelDbObject.SelectAllFromTable(excelSheetSelector.SelectedSheetName);
                    ExcelImporter importer = new ExcelImporter();
                    importer.Import(dataTable);
                }

            }

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            if (MonthPicker.SelectedDate != null)
            {
                CalenderWindow calenderWindow = new CalenderWindow();
                calenderWindow.Date = Convert.ToDateTime(MonthPicker.SelectedDate);
                calenderWindow.ShowDialog();
            }
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            QueryWindow queryWindow = new QueryWindow();
            queryWindow.ShowDialog();
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            StaffWindow staffWindow = new StaffWindow();
            staffWindow.ShowDialog();
        }

        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            ApplyOvertimeWorkWindow applyOvertimeWorkWindow = new ApplyOvertimeWorkWindow();
            applyOvertimeWorkWindow.ShowDialog();
        }
    }
}
